package com.zdoon.controller;

import com.zdoon.pojo.Result;
import com.zdoon.utils.AliyunOSSOperator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;



@Slf4j
@RestController
public class UploadController {

    @Autowired
    private AliyunOSSOperator  aliyunOSSOperator;


    @PostMapping("/upload")
    public Result upload(String name, Integer age, MultipartFile file) throws Exception {
        log.info("file upload: {},{},{}",name,age,file);
//        将文件交给oss存储管理
        String uploadUrl = aliyunOSSOperator.upload(file.getBytes(), file.getOriginalFilename());

        return Result.success(uploadUrl);
    }

}
